package com.gameShare.controller.user

import com.gameShare.controller.base.LoginVerifyController
import com.gameShare.entity.vo.ResponseVo
import com.gameShare.enums.user.UserActionEnum
import com.gameShare.enums.user.UserFocusSelectType
import com.gameShare.service.user.UserActionService
import com.gameShare.service.user.UserCenterService
import com.gameShare.service.user.UserFocusService
import entity.dto.user.UserCenterUserInfoDto
import jakarta.servlet.http.HttpServletRequest
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/userCenter")
class UserCenterController(
    private val userCenterService: UserCenterService,
    private val useActionService: UserActionService,
    private val userFocusService: UserFocusService
) : LoginVerifyController() {


    @RequestMapping("/loadUserAllActionCounts")
    fun loadUserAllActionCounts(request: HttpServletRequest): HashMap<String, Int> {
        val userId = getUserInfoByToken(request).id
        return useActionService.loadUserAllActionCount(userId)
    }

    @RequestMapping("loadFocusCount")
    fun loadFocusCount(httpServletRequest: HttpServletRequest, userId : String?, selectType : Int?): ResponseVo<Int> {
        return getSuccessResponseVO(userFocusService.loadFocusCount(
            userId ?: getUserIdByToken(httpServletRequest),
            selectType ?: UserFocusSelectType.FOCUS.code
        ))
    }

    @RequestMapping("/loadUserInfo")
    fun loadUserInfo(@RequestParam userId : String): ResponseVo<UserCenterUserInfoDto> {
        return getSuccessResponseVO(userCenterService.loadUserInfo(userId))
    }
}